
export default {
    data() {
        return {
          empty:'/static/logo.png',
          userInfo:{},
          imId:'32186210'
        }
    },
    created() {

    },
    methods: {
     
		stopEvent:function(){
            console.log('阻止冒泡')
        },
        navigationTo: function(link, query) {
            console.log(link, query)
            let str = '?'
            let arr =[];
            if(query != undefined){
                for(let i in query){
                    arr.push(`${i}=${query[i]}`)
                }
              str = str + arr.join('&')
            }
         
            uni.navigateTo({ url: link + str })
        },
        navBack: function({ delta = 1 }) {
            uni.navigateBack({ delta: delta })
        },
        openImg:function(arr){
            uni.previewImage({
                urls: arr,
                success: (result) => {},
                fail: (error) => {}
            })
        },
        uniToast:function(info){
            uni.showToast({
                title: info,
                icon: 'none',
                mask: true
            })
        },
        getUserInfo:function(){
            this.$post('/api/user/center',
                { },true
                    ).then(res => {
                    if (res.code == 1) {
                        this.userInfo = res.data || {};
                        let user = res.data;
                        // uni.setStorage({
                        //     key: 'myUsername',
                        //     data:user.id +''
                        // })
                        // getApp().globalData.conn.open({
                        //     apiUrl: WebIM.config.apiURL,
                        //     user: user.id+'',
                        //     pwd: user.huanxin_pwd,
                        //     // grant_type: this.grant_type,
                        //     appKey: WebIM.config.appkey
                        // })
                        //  getApp().globalData.conn.open({
                        //     apiUrl: WebIM.config.apiURL,
                        //     user: '0001',
                        //     pwd: '123123',
                        //     // grant_type: this.grant_type,
                        //     appKey: WebIM.config.appkey
                        // })
                }else{
                  this.uniToast(res.msg)
                }
                 }).finally(() => {
                 })
        },
        handleImg:function(str){
            let arr = [];

            if(str.indexOf(',') != -1){
             
            arr = str.split(',')

              }else{
               arr.push(str)
              }
            return arr;
        },
        formatRichText: function(html) {
			let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
				match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
				match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
				match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
				return match;
			});
			newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
				match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
					'max-width:100%;');
				return match;
			});
			newContent = newContent.replace(/<br[^>]*\/>/gi, '');
			newContent = newContent.replace(/\<img/gi,
				'<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
			return newContent;
		}
    }
}